/**
 * CoffeeMilk (C) 2010 Amen Hamdan
 * 
 * See the NOTICE file distributed with this work for additional 
 * information regarding copyright ownership.  This file is licenses
 * to you under the Apache License, Version 2.0 (the "License"); you 
 * may not use this file except in compliance with the License.  You 
 * may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 *     
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
 * implied. See the License for the specific language governing 
 * permissions and limitations under the License.    
 * 
 */
package ameen.rtm.coffeemilk.persistency;

import java.awt.SystemTray;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;

import ameen.rtm.lib.RtmServiceSettings;
import ameen.rtm.lib.types.AuthToken;

public class SettingsStore implements RtmServiceSettings {
	private final String API_KEY 			= "";
	private final String SHARED_SECRET 		= "";

	public static  final String SYSTEMTRAY_ENABLED	= "SettingsStore.systemTrayEnabled";
	
	public static final int UNSET 			= -1;
	private int mainWindowWidth 			= UNSET;
	private int mainWindowHeight 			= UNSET; 
	
	private String frob;
	private AuthToken authToken;
	private String timeline;
	private boolean minimizeToTray = false;
	private boolean systemTrayEnabled = SystemTray.isSupported();
	private PropertyChangeSupport fPropertyChangeSupport = new PropertyChangeSupport(this);

	public void addPropertyChangeListener(PropertyChangeListener listener) {
		this.fPropertyChangeSupport.addPropertyChangeListener(listener);
	}
	
	public void removePropertyChangeListener(PropertyChangeListener listener) {
		this.fPropertyChangeSupport.removePropertyChangeListener(listener);
	} 	
	
	public AuthToken getAuthToken() {
		return authToken;
	}

	public void setAuthToken(AuthToken authToken) {
		this.authToken = authToken;
	}

	public String getFrob() {
		return frob;
	}

	public void setFrob(String frob) {
		this.frob = frob;
	}

	public String getApiKey() {
		return API_KEY;
	}

	public String getSharedSecret() {
		return SHARED_SECRET;
	}

	public String getTimeline() {
		return timeline;
	}

	public void setTimeline(String timeline) {
		this.timeline = timeline;
	}

	public int getMainWindowWidth() {
		return mainWindowWidth;
	}

	public void setMainWindowWidth(int mainWindowWidth) {
		this.mainWindowWidth = mainWindowWidth;
	}

	public int getMainWindowHeight() {
		return mainWindowHeight;
	}

	public void setMainWindowHeight(int mainWindowHeight) {
		this.mainWindowHeight = mainWindowHeight;
	}

	public boolean isMinimizeToTray() {
		if(isSystemTrayEnabled()) {
			return minimizeToTray;
		} else {
			return false;
		}
	}

	public void setMinimizeToTray(boolean minimizeToTray) {
		boolean oldValue = this.minimizeToTray;
		this.minimizeToTray = minimizeToTray;
		fPropertyChangeSupport.firePropertyChange(SYSTEMTRAY_ENABLED, oldValue, this.minimizeToTray);
	}

	public boolean isSystemTrayEnabled() {
		return systemTrayEnabled;
	}
}
